#ifndef PLAYLISTBASEMODEL_H
#define PLAYLISTBASEMODEL_H

#include "EZTallyObject.h"
#include <QList>
#include <QMap>
#include "EZTallyArray.h"
#include "songmodel.h"
#include "EZTallyDictionary.h"
#include "EZTallyAutoPtr.h"
#include <QList>

class PlayListBaseModel;

class PlayListBaseModelDelegate
{
public:
    virtual void onSongChange(PlayListBaseModel */*sender*/,EZTally::EZTallyArray<SongModel*> */*oldSong*/){}
};

class PlayListBaseModel :public QObject , public EZTally::EZTallyObject
{
private:
    Q_OBJECT
protected:
    virtual ~PlayListBaseModel();
public:
    PlayListBaseModel();
public:
    enum QUEUE_TYPE{
        QUEUE_TYPE_RepeatList,
        QUEUE_TYPE_RandPlay,
        QUEUE_TYPE_RepeatOne
    };

public:

    QUEUE_TYPE getPlayQueueType() const;
    virtual  void setPlayQueueType(const QUEUE_TYPE &value);

    int getCurIndex() const;
    virtual void setCurIndex(int value);

    EZTally::EZTallyArray<SongModel*> *getSongs() const;
    int count();
    int indexOfSong(SongModel *song);
    SongModel* songAtIndex(int index);

public:
    virtual SongModel* nextSong(int *outIndex);
    virtual SongModel* previoursSong(int *outIndex);
    virtual SongModel* curSong();

    virtual int wantGetMoreSong();


public:


    EZTally::EZTallyObject *getUserData(const std::string &key);
    void setUserData(const std::string &key,EZTally::EZTallyObject *objData);
    QVariant getUserData(const QString &key);
    void setUserData(const QString &key,const QVariant &value);

    void addDelegate(PlayListBaseModelDelegate*);
    void removeDelegate(PlayListBaseModelDelegate*);

    QString name() const;
    void setName(const QString &name);

protected:
    QUEUE_TYPE playQueueType;
    EZTally::EZTallyArray<SongModel*> *songs;
    int curIndex;

    EZTally::EZTallyDictionary<std::string,EZTally::EZTallyObject*> *userDataDic;
    QMap<QString,QVariant> _userDataMap;

    QList<PlayListBaseModelDelegate*> _listDelegate;

    QString _name;
signals:
    void songsChange(const EZTally::EZTallyAutoPtr &oldSong);
    void sigPlayQueueTypeChange();
};

#endif // PLAYLISTBASEMODEL_H
